package cn.tedu.lucky.draw.server.repository;

import cn.tedu.lucky.draw.server.protocol.po.Activity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface ActivityRepository extends JpaRepository<Activity,Long> {

    //根据活动名称和活动状态结合sort字段进行升序查询
    List<Activity> findByNameAndStatusOrderBySortAsc(String name,Integer status);

    //查询ID在34-40之间的活动 查询条件：id   between
    List<Activity> findByIdBetween(Long start,Long end);

    //查询时间已经结束的活动信息，结束时间在当前时间之前
    Page<Activity> findByStatusAndEndTimeBefore(Integer status, LocalDateTime now, Pageable pageable);

    List<Activity> findByStatus(Integer status);
}
